import * as actionTypes from './constants';
import { 
  getRankingList
} from '@/services/ranking'

const changeFeatureRankingListAction = (res) => ({
  type:actionTypes.LIST_DATA_FEATURE,
  featureRanking:res
})

const changeMediaRankingListAction = (res) => ({
  type:actionTypes.LIST_DATA_MEDIA,
  mediaRanking:res
})

export const getRankingListAction = () => {
  return dispatch => {
    getRankingList().then(res => {
      console.log("res",res);
      let FeatureRanking = res.list.slice(0,4);
      let MediaRank = res.list.slice(4);
      console.log(FeatureRanking);
      console.log(MediaRank);
      dispatch(changeFeatureRankingListAction(FeatureRanking));
      dispatch(changeMediaRankingListAction(MediaRank));
    })
  }
}